load("@io_bazel_rules_webtesting//web:web.bzl", "browser")
load("@npm//@angular/build-tooling/bazel/browsers:browser_toolchain_alias.bzl", "browser_toolchain_alias")

package(default_visibility = ["//visibility:public"])

PLATFORM_METADATA = select({
    "@npm//@angular/build-tooling/bazel/constraints:linux_x64": [
        "@org_chromium_chromedriver_linux_x64//:metadata",
        "@org_chromium_chromium_linux_x64//:metadata",
    ],
    "@npm//@angular/build-tooling/bazel/constraints:macos_x64": [
        "@org_chromium_chromedriver_macos_x64//:metadata",
        "@org_chromium_chromium_macos_x64//:metadata",
    ],
    "@npm//@angular/build-tooling/bazel/constraints:macos_arm64": [
        "@org_chromium_chromedriver_macos_arm64//:metadata",
        "@org_chromium_chromium_macos_arm64//:metadata",
    ],
    "@npm//@angular/build-tooling/bazel/constraints:windows_x64": [
        "@org_chromium_chromedriver_windows//:metadata",
        "@org_chromium_chromium_windows//:metadata",
    ],
})

browser(
    name = "chromium",
    metadata = "chromium.json",
    deps = PLATFORM_METADATA + [
        "@io_bazel_rules_webtesting//go/wsl",
    ],
)

browser_toolchain_alias(
    name = "toolchain_alias",
    deps = PLATFORM_METADATA,
)

# Make source files available for distribution via pkg_npm
filegroup(
    name = "files",
    srcs = glob(["*"]),
)
